package com.example.service;

import com.example.entity.Clock;
import com.example.entity.Clockingtime;
import com.example.mapper.ClockMapper;
import com.example.mapper.ClockingtimeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
闹钟业务处理
 */
@Service
public class ClockService {

    @Resource
    private ClockMapper clockMapper;

    public void add(Clock clock) {
        clockMapper.insert(clock);
    }

    public void deleteById(Integer id) {
        clockMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Clock clock) {
        clockMapper.updateById(clock);
    }

    public Clock selectById(Integer id) {
        return clockMapper.selectById(id);
    }

    public List<Clock> selectAll(Clock clock) {
        return clockMapper.selectAll(clock);
    }

    public PageInfo<Clock> selectPage(Clock clock, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Clock> clockList = clockMapper.selectAll(clock);
        return PageInfo.of(clockList);
    }
}
